#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int N = 1e5 + 10;
int res[N];
int dp[N][4];
int C[20][20];
int qpow(int x,int p){
    int res = 1;
    while(p){
        if(p & 1){
            res = 1ll*res*x%MOD;
        }
        x = 1ll*x*x%MOD;
        p>>=1;
    };
    return res;
}
int inv[20];
int main(){
    int n;
    cin>>n;
    C[0][0] = 1;
    for(int i = 1;i<20;i++){
        C[i][0] = 1;
        for(int j = 1;j < 20;j++){
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1])%MOD;
        }
    }
    inv[0] = 1;
    for(int j = 1;j < 20;j++){
        inv[j] = qpow(j,MOD - 2);
    }
    res[0] = 1;
    dp[0][0] = 1;
    dp[0][1] = dp[0][2] = dp[0][3] = 1;
    for(int i = 1;i<=n;i++){
        res[i] = dp[i - 1][3];
        for(int j = n;j >= i;j--){
            for(int k = 1;k <= 3;k++){
                for(int w = 1;w <= k && i*w <= j;w++){
                    int rr = 1;
                    for(int t = 1;t <= w;t++){
                        rr = 1ll*rr*(res[i] - t + 1)%MOD*inv[t]%MOD;
                        dp[j][k] = (dp[j][k] + 1ll*dp[j - i*w][k - w]*C[w - 1][t - 1]*rr%MOD)%MOD;
                    }
                }
            }
        }
    }
    cout<<res[n]<<'\n';
}